{layout name="layout" /}

<div class="Hui-article">
	<article class="cl pd-20">
		<form action="" method="post" class="form form-horizontal" id="form-admin-powers-add">
			<input type="hidden" name="id" value="{$data.id}">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">上级权限</label>
				<div class="formControls col-xs-8 col-sm-2">
					<span class="select-box" style="width:150px;">
						<select class="select" id="pid" name="pid">
							<option value="0" {eq name='data.pid' value="0" }selected{/eq}>--顶级权限--</option>
							{foreach $powers as $value}
							<option value="{$value.id}" {eq name='data.pid' value="$value.id" }selected{/eq}>----{$value.name}----</option>
							{notempty name="value.child"} {foreach $value.child as $val}
							<option value="{$val.id}" {eq name='data.pid' value="$val.id" }selected{/eq}>└-----{$val.name}--</option>
							{/foreach} {/notempty} {/foreach}
						</select>
					</span>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">
					<span class="c-red">*</span>权限名称：</label>
				<div class="formControls col-xs-6 col-sm-3">
					<input type="text" class="input-text" value="{$data.name}" placeholder="请输入权限名称" id="name" name="name" />
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">
					<span class="c-red">*</span> icon or Controller or method：</label>
				<div class="formControls col-xs-6 col-sm-3">
					{eq name="data.pid" value="0"}
					<input type="text" class="input-text" value="{$data.method|str_replace='&', '&amp;', ###}" placeholder="请输入控制器或方法名" id="method"
					    name="method" />
					<span  style="color: crimson;">图标样式: </span><i class="Hui-iconfont">{$data.method}</i>
					{else/}
					<input type="text" class="input-text" value="{$data.method}" placeholder="请输入控制器或方法名" id="method" name="method" /> {/eq}
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">
					<span class="c-red">*</span> 说 明 ： </label>
				<div class="formControls col-xs-6 col-sm-4">
					<span style="color:red;">顶级权限填入图标(
						<a href="/static/h-ui/lib/Hui-iconfont/1.0.8/demo.html" target="_blank" style="color: blue;">图标示例</a>);
						<br/> 控制器(Controller)填入小写字母, 大驼峰命名的转为小写加下划线, 示例:
						<pre> AdminUser ====> admin_user</pre>
						<br/> 方法名(method)填入小写字母, 驼峰的直接转小写, 示例:
						<pre>getName  ====> getname</pre>
					</span>
				</div>
			</div>
			<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">
						<span class="c-red">*</span>是否为侧栏目录：</label>
					<div class="formControls col-xs-6 col-sm-2 skin-minimal">
						<div class="radio-box">
							<input name="menu" type="radio" id="sex-1" value="1" {eq name="data.menu" value="1"}checked{/eq}>
							<label for="sex-1">是</label>
						</div>
						<div class="radio-box">
							<input name="menu" type="radio" id="sex-2" value="0" {eq name="data.menu" value="0"}checked{/eq}>
							<label for="sex-2">否</label>
						</div>
					</div>
					<label class="form-label col-xs-4 col-sm-1">
							<span class="c-red">*</span>状态：</label>
						<div class="formControls col-xs-6 col-sm-2 skin-minimal">
							<div class="radio-box">
								<input name="status" type="radio" id="sex-1" value="1" {eq name="data.status" value="1"}checked{/eq}>
								<label for="sex-1">正常</label>
							</div>
							<div class="radio-box"> 
								<input name="status" type="radio" id="sex-2" value="2" {eq name="data.status" value="2"}checked{/eq} >
								<label for="sex-2">停用</label>
							</div>
						</div>
				</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">备注：</label>
				<div class="formControls col-xs-8 col-sm-4">
					<textarea id="note" name="note" cols="" rows="" class="textarea" placeholder="备注...100个字符以内" dragonfly="true" onKeyUp="textarealength(this,100)">{$data.note}</textarea>
					<p class="textarea-numberbar">
						<em class="textarea-length">0</em>/100</p>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<button type="submit" class="btn btn-success radius" id="admin-powers-save" name="">
						<i class="icon-ok"></i> 确&nbsp;定</button>
					<button type="button" class="btn btn-default radius" onclick="window.history.back();">
						<i class="icon-ok"></i> 取&nbsp;消</button>
				</div>
			</div>
		</form>
	</article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	$(function () {
		$("#form-admin-powers-add").submit(function () {
			var desc = $("#note").val();

			if (!$("#name").val() || !$("#method").val) {
				layer.msg('权限名 or 控制器/方法', {
					icon: 5,
					time: 1000
				});

				return false;
			}

			if (getblen(desc) > 100) {
				layer.msg('备注过长', {
					icon: 5,
					time: 1000
				});

				return false;
			}
		})
	})
</script>